<template>
	<view>
	<view class="head dixian">
		<text class="color" @click="back">返回</text>
		<text>日常检查</text>
		<text class="color" @click="add">新增</text>
	</view>
	<view class="ipt dixian">
<uni-easyinput class="uni-mt-5" suffixIcon="search" v-model="data.ipt" placeholder="请输入单位名称" @iconClick="check" @focus='huoqu' :inputBorder="false"></uni-easyinput>
	</view>
	<view class="content dixian" v-for="(item,index) in data.shujudata" :key="index" @click="chakan(item.dwname)">
		<view class="content_item">
			<text>单位名称</text>
			<text>{{item.dwname}}</text>
		</view>
		<view class="content_item">
			<text>检查日期</text>
			<text>{{item.jctime}}</text>
		</view>
		<view class="content_item active">
			<text>检查结果</text>
			<text>{{item.jiancha}}</text>
			
		</view>
	</view>
	</view>
	</template>

<script>
	import { reactive,onMounted } from 'vue'
	import {useStore} from "vuex"
	import http from '../../utils/http.js'
	export default {
		setup(){
			let data=reactive({
				shujudata:[],
				ipt:''
			})

			let back=()=>{
				uni.navigateTo({
					url:'./check'
				})
			}
			let add=()=>{
				uni.navigateTo({
					url:'./richangadd'
				})
			}
			let getdata=()=>{
				http({
							   url:'/jiliang/jianchadate',
							   method:'post'
				}).then((res)=>{
							   if(res.data.data.length>0){
								   let shuju=res.data.data
								for(let i=0;i<shuju.length;i++){
								   				   shuju[i].jctime=shuju[i].jctime.substring(0,10)
										
								   }
								   data.shujudata=shuju
								   
							   }
				})  
			}
			onMounted(() => {
			   getdata()
			     })
			let check=()=>{
					   console.log(data.ipt)
					   let shuju=[]
					   for(let i=0;i<data.shujudata.length;i++){
						   if(data.ipt==data.shujudata[i].dwname){
							   shuju.push(data.shujudata[i])
						   }
					   }
					   data.shujudata=shuju
			}
			let huoqu=()=>{
					   getdata()
			}
			let chakan=(v)=>{
			uni.navigateTo({
					url:'./jianchakan?name='+encodeURIComponent(v)
				})
			}
			return{
				back,
				add,
				getdata,
				data,
				check,
				huoqu,
				chakan
		}
	}
	}
</script>

<style lang="less">
.head{
	display: flex;
	justify-content: space-around;
	padding: 20rpx 0;
}
.color{
	color:#57A7FE;
}
.dixian{
	border-bottom: 1rpx solid #898989;
}
.ipt{
	padding: 10rpx 0;
	input{
		padding-left: 45rpx;
		text-indent:15rpx;
		border: 1rpx solid #898989;
		border-radius: 40rpx;
		height: 80rpx;
		line-height: 80rpx;
	}
}
.content{
	display: flex;
	flex-direction: column;
	padding: 30rpx 35rpx;
	
}
.content_item{
	display: flex;
	
	text:first-child{
		color:#666666 ;
		flex: 1;
		font-weight:bold;
	}
		text:last-child{
			color:#898989 ;
			flex: 2;
	}
	}
</style>
